/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.biblioteca.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.biblioteca.modelo.CategoriaDeLibro;
import mx.its.dsw2.biblioteca.modelo.Libro;

/**
 *
 * @author 100101
 */
@Stateless
public class CategoriaDeLibroDao extends AbstractDao<CategoriaDeLibro> implements CategoriaDeLibroDaoLocal {
    @PersistenceContext(unitName = "Biblioteca8E-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CategoriaDeLibroDao() {
        super(CategoriaDeLibro.class);
    }

    @Override
    public List<CategoriaDeLibro> getListByBook(Libro book) {
        Query q=em.createNamedQuery("CategoriaDeLibro.findByIdLibro");
        q.setParameter("idLibro", book.getId());
        return q.getResultList();
        
    }
    
    
    
}
